package com.aqie.easy.linkedlist;

import com.aqie.easy.structure.ListNode;

/**
 * 83 删除排序链表重复元素
 */
public class DeleteDuplicates {
    /**
     * 判断当前节点及下个节点是否重复， 重复则改变当前节点的next指针 1ms
     * @param head
     * @return
     */
    public ListNode deleteDuplicates(ListNode head) {
        ListNode current = head;
        while (current != null && current.next != null) {
            if (current.next.val == current.val) {
                current.next = current.next.next;
            } else {
                current = current.next;
            }
        }
        return head;
    }
}
